//
//  MineSetViewController.m
//  Weiweiyunshi
//
//  Created by 王译 on 17/2/5.
//  Copyright © 2017年 王译. All rights reserved.
//

#import "MineSetViewController.h"
#import "ChangePwdViewController.h"
@interface MineSetViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *setTableView;
    UISwitch *wifiSwitch;
}
@end

@implementation MineSetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置";
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"header_back_icon"] style:UIBarButtonItemStyleDone target:self action:@selector(pop)];
    self.navigationItem.leftBarButtonItem = backItem;
    [self createTableView];
    // Do any additional setup after loading the view.
}
-(void)pop
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)createTableView{
    setTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT) style:UITableViewStyleGrouped];
    setTableView.delegate = self;
    setTableView.dataSource = self;
    setTableView.scrollEnabled = NO;
    setTableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
    [self.view addSubview:setTableView];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 2;
    }else if (section ==1){
        return 1;
    }else{
        return 1;
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    

    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    if (indexPath.section == 0 ) {
        switch (indexPath.row) {
            case 0:
                cell.textLabel.text = @"修改密码";
                break;
            case 1:
                cell.textLabel.text = @"更换手机号";
                break;
            default:
                break;
        }
    }else if (indexPath.section ==1){
        wifiSwitch = [[UISwitch alloc]initWithFrame:CGRectZero];
        cell.accessoryView = wifiSwitch ;
        [wifiSwitch addTarget:self action:@selector(wifiSwitchChange:) forControlEvents:UIControlEventValueChanged];
        cell.textLabel.text = @"仅限wifi网络下启动视频";
    }else{
        cell.textLabel.text = @"关于娓娓云视";
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return  cell;
}

-(void)wifiSwitchChange:(id)sender{
    if ([sender isOn]) {
        NSLog(@"打开");
    }else
        NSLog(@"关闭");
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0 &&indexPath.row ==0) {
        [self.navigationController pushViewController:[ChangePwdViewController alloc] animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
